import { ref, shallowRef, VNode } from "vue"
import Drawer from "../component/drawer.vue";
import Main from "../main";

export default (main:Main) => {
    const enabled = ref(true)

    const visible = ref(false)
    const vnode = shallowRef<VNode>();
    const maxSize = "100%";
    const minSize = '30%'
    //
    const open = (node?:VNode) => {
        vnode.value = node;
        visible.value = true;
    }

    const close = () => {
        visible.value = false;
        vnode.value = undefined;
    }

    const set = (node?:VNode) => {
        if(node){
            vnode.value = node;
        }   
        else{
            close();
        }
    }



    return {
        enabled,
        Drawer,
        props:{visible,vnode,maxSize,minSize},
        open,
        close,
        set
    }
}